package com.seven.sevenrainbow;

import android.animation.Animator;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.romainpiel.shimmer.Shimmer;
import com.romainpiel.shimmer.ShimmerTextView;

/**
 * 闪动的文字
 */
public class ShimmerActivity extends AppCompatActivity {

    private ShimmerTextView myShimmerTextView;
    private Shimmer shimmer;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shimmeer);
        myShimmerTextView = findViewById(R.id.shimmer_tv);
        shimmer = new Shimmer();
        shimmer.setRepeatCount(-1)
                .setDuration(1500)
                .setStartDelay(300)
                .setDirection(Shimmer.ANIMATION_DIRECTION_LTR)
                .setAnimatorListener(new Animator.AnimatorListener(){
                    @Override
                    public void onAnimationStart(Animator animation) {

                    }

                    @Override
                    public void onAnimationEnd(Animator animation) {

                    }

                    @Override
                    public void onAnimationCancel(Animator animation) {

                    }

                    @Override
                    public void onAnimationRepeat(Animator animation) {

                    }
                });
    }

    @Override
    protected void onResume() {
        super.onResume();
        shimmer.start(myShimmerTextView);
    }

    @Override
    protected void onStop() {
        super.onStop();
        shimmer.cancel();
    }
}
